Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrated make_latest property of gh api publish #884

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mchambaud
Copy link

Fixes #817

@mchambaud
Copy link
Author

mchambaud commented Jul 30, 2024

@travi @babblebey any chance we can re-run the tests, code has been linted. Let me know if more changes are needed.

@babblebey
Copy link
Member

babblebey commented Jul 30, 2024

...any chance we can re-run the tests, code has been linted. Let me know if more changes are needed.

Hey @mchambaud, tests re-ran and they are failing at the publish lifecycle part.

I have gone on and tested your changes itself and I'm getting the error below...

For 'properties/make_latest', true is not a string. - https://docs.github.com/rest/releases/releases#create-a-release
    at file:///C:/Users/User/Documents/Projects/open-source/semantic-release/github/node_modules/@octokit/request/dist-bundle/index.js:106:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async requestWithGraphqlErrorHandling (file:///C:/Users/User/Documents/Projects/open-source/semantic-release/github/node_modules/@octokit/plugin-retry/dist-bundle/index.js:36:20)
    at async Job.doExecute (C:\Users\User\Documents\Projects\open-source\semantic-release\github\node_modules\bottleneck\light.js:405:18) {
  status: 422,
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/babblebey/sr-github/releases',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': '@semantic-release/github v0.0.0-development octokit-core.js/6.1.2 Node.js/20.9.0 (win32; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"tag_name":"v2.0.0","target_commitish":"main","name":"v2.0.0","body":"# [2.0.0](https://github.com/babblebey/sr-github/compare/v1.9.0...v2.0.0) (2024-07-30)\\n\\n\\n### Features\\n\\n* **doc:** init beta branch ([0491f73](https://github.com/babblebey/sr-github/commit/0491f730312a3e1973ad4034f881ec2d3d6ca5c1))\\n* **doc:** testing pre-release ([1e1bef6](https://github.com/babblebey/sr-github/commit/1e1bef62cf4bdb4e1bbebefdfc4f729e7c404f1a))\\n\\n\\n### BREAKING CHANGES\\n\\n* **doc:** i just wann see how this works\\n\\n\\n\\n","prerelease":false,"make_latest":true}',
    request: { agent: undefined, hook: [Function: bound bound register] }        
  },
  response: {
    url: 'https://api.github.com/repos/babblebey/sr-github/releases',
    status: 422,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-length': '186',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Tue, 30 Jul 2024 16:41:04 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-oauth-scopes': 'repo',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '6A23:2280DD:262B1A8:26861AC:66A917A0',
      'x-oauth-scopes': 'repo',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4958',
      'x-ratelimit-reset': '1722358969',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '42',
      'x-xss-protection': '0'
    },
    data: {
      message: "Invalid request.\n\nFor 'properties/make_latest', true is not a string.",
      documentation_url: 'https://docs.github.com/rest/releases/releases#create-a-release',
      status: '422'
    }
  },
  pluginName: '@semantic-release/github'
}

..and the reason for this error, I am currently investigating as it could infact be anything from my setup... BUT in the meantime, kindly confirm whether and how you were able to test this changes 😉

@babblebey
Copy link
Member

Hey @mchambaud, following my further investigation and testing.....

It appears as though, the make_latest is preferred as an inferred value instead of explicitly stating it. This means you're to infer the a false or true value for make_latest from the value of prerelease which is exactly as it is in our current set-up.

When prerelease is true, make_latest is inferred as false or the other way round.

I assumed this to be the case due to the version of the GitHub API we're consuming... But it turns that the API version has nothing to with it, following a version specification I added to the POST release request in testing.

I believe the make_latest might be best consumed or used when you're trying to update a release... If the release is already prerelease or an older release for example 🤔

@rglidden
Copy link

rglidden commented Oct 2, 2024

It appears as though, the make_latest is preferred as an inferred value instead of explicitly stating it. This means you're to infer the a false or true value for make_latest from the value of prerelease which is exactly as it is in our current set-up.

I'm running into #817 and came across this PR. I'm not quite sure I understand this comment though. Looking through the API documentation you linked, it looks like there is some relationship between the two flags, but you can't completely infer one from the other.

prerelease make_latest
= true inferred false
= false can be true or false
inferred false = true
can be true or false = false

That is, if either option is explicitly set to true, then the value of the other option should be inferred. However, the case with maintenance releases is where both options need to be false, because it is neither a pre-release nor is it the latest release.

Basically, if either option is false, then you can't infer the value of the other option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to not mark maintenance releases as latest
3 participants